#include "dev/dacai/memory/nw_mem.h"
#include "dev/dacai/memory/memory.h"
#include "dev/dacai/driver/driver.h"
#include "dev/mem.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"

struct boot{
    struct t_screendeal screendeal;
};
struct main_waitgun{
	 struct t_screendeal screendeal;
};
struct way_select{
	 struct t_screendeal screendeal;
};
struct waitpwd{
	 struct t_screendeal screendeal;
};
struct worktypeset{
	 struct t_screendeal screendeal;
};
struct workvalue_time{
	 struct t_screendeal screendeal;
};
struct workvalue_power{
	 struct t_screendeal screendeal;
};
struct workvalue_money{
	 struct t_screendeal screendeal;
};
struct waitgun{
	 struct t_screendeal screendeal;
};
struct charging{
	 struct t_screendeal screendeal;
};
struct charging_cost{
	 struct t_screendeal screendeal;
};
struct settle{
	 struct t_screendeal screendeal;
};
struct alarm{
	 struct t_screendeal screendeal;
};
struct waitpwdmanage{
	 struct t_screendeal screendeal;
};
struct sysset1{
	 struct t_screendeal screendeal;
};
struct sysset2{
	 struct t_screendeal screendeal;
};
struct sysset3{
	 struct t_screendeal screendeal;
};
struct sysset4{
	 struct t_screendeal screendeal;
};
struct chargerecord{
	 struct t_screendeal screendeal;
};
struct alarmrecord{
	 struct t_screendeal screendeal;
};


enum{
	E_SCREEN_BOOT	= 0,//	启动界面
	E_SCREEN_MAIN_WAITGUN,	//1	主界面
	E_SCREEN_WAYSELECT,	//2	选择启动方式界面
	E_SCREEN_WAITPWD,	//3	等待输入密码界面
	E_SCREEN_WORKTYPE_SET,	//4	设置充电类型界面
	E_SCREEN_WORKVALUE_SET_TIME,	//5	设置充电时间
	E_SCREEN_WORKVALUE_SET_POWER,	//6	设置充电电量
	E_SCREEN_WORKVALUE_SET_MONEY,	//7	设置充电时长
	E_SCREEN_WAITGUN,	//8	等待枪连接界面
	E_SCREEN_CHARGING,	//9	充电中界面
	E_SCREEN_CHARGING_COST,	//10	充电中界面_费用信息
	E_SCREEN_SETTLE,	//11	结算界面
	E_SCREEN_ALARM,	//12	告警界面
	E_SCREEN_WAITPWD_MANAGE,	//13	等待输入密码界面(管理界面)
	E_SCREEN_SYSSET1,	//14	系统设置1
	E_SCREEN_SYSSET2,	//15	系统设置2
	E_SCREEN_SYSSET3,	//16	系统设置3
	E_SCREEN_SYSSET4,	//17	系统设置4
	E_SCREEN_CHARGERECORD,	//18	充电记录
	E_SCREEN_ALARMRECORD,	//19	告警记录
};

enum{
	E_CONTROL_BASE = 0,
//按钮控件
  E_BUTTON_MANAGE,//	1	系统设置
  E_BUTTON_CANCEL,//	2	取消
  E_BUTTON_MAKESURE,//	3	确定
  E_BUTTON_BYAUTO,//	4	自动充满
  E_BUTTON_BYTIME	,//5	按时间充
  E_BUTTON_BYPOWER,//	6	按度数充
  E_BUTTON_RETURN	,//7	返回
  E_BUTTON_SYSSET,//	8	参数设置
  E_BUTTON_RECORDCHECK,//	9	记录查看
  E_BUTTON_DEBUG,//	10	调试窗口
  E_BUTTON_ABOUTDEV,//	11	关于设备
  E_BUTTON_REBOOT	,//12	重启
  E_BUTTON_SAVE	,//13	保存
  E_BUTTON_FRONT,//	14	上一页
  E_BUTTON_NEXT	,//15	下一页
  E_BUTTON_STOP	,//16	停止充电
	
	E_BUTTON_ALARMDETAIL = E_CONTROL_BASE+20,//详细告警内容控件
	
  //E_BUTTON_ALARMDETAIL+1
  //E_BUTTON_ALARMDETAIL+2		
  //E_BUTTON_ALARMDETAIL+3		
  //E_BUTTON_ALARMDETAIL+4	
  //...		...
  //E_BUTTON_ALARMDETAIL+N		备份控件N
  E_BUTTON_GUN  = E_CONTROL_BASE + 40,//+1	E_BUTTON_GUN = 40	充电枪1
  //E_BUTTON_GUN +2		充电枪2
  //...		...
  //E_BUTTON_GUN +N		充电枪n
	E_BUTTON_KEYBOARDBASE = 60,//键盘
  E_BUTTON_KEYBOARD1	,//61	键盘1
  E_BUTTON_KEYBOARD2	,//62	键盘2
  E_BUTTON_KEYBOARD3	,//63	键盘3
  E_BUTTON_KEYBOARD4	,//64	键盘4
  E_BUTTON_KEYBOARD5	,//65	键盘5
  E_BUTTON_KEYBOARD6	,//66	键盘6
  E_BUTTON_KEYBOARD7	,//67	键盘7
  E_BUTTON_KEYBOARD8	,//68	键盘8
  E_BUTTON_KEYBOARD9	,//69	键盘9
  E_BUTTON_KEYBOARD_BACKSPACE	,//70	键盘 backsapce
  E_BUTTON_KEYBOARD_0	,//71	键盘0
  E_BUTTON_KEYBOARD_POINT	,//72	键盘小数点
  E_BUTTON_CHARGERECORD	,//73	充电记录
  E_BUTTON_ALARMRECORD	,//74	告警记录
//文本类
    E_TEXT_BASE = E_CONTROL_BASE + 80,//文本控件基准
    E_TEXT_COMPANYNAME,//	1	公司名称
    E_TEXT_VERUI,//	2	UI版本号
    E_TEXT_VERSOFTWARE,//	3	设备软件版本号
    E_TEXT_DEVNUM,//	4	桩编号
    E_TEXT_TITLE1,//	5	标题1
    E_TEXT_TITLE2,//	6	标题2
    E_TEXT_TELRPHONE,//	7	客服热线
    E_TEXT_WEB,//	8	官方网站
    E_TEXT_GUNNO,//	9	枪号
    E_TEXT_POINTMSG,//	10	提示信息
    E_TEXT_CARDNO,//	11	卡号
    E_TEXT_PASSWORD,//	12	密码
    E_TEXT_PARASET_TITLE,//13	设置充电参数_标题
    E_TEXT_PARASET_VALUE,//14	设置充电参数_值
    E_TEXT_PARASET_UNIT,//15	设置充电参数_单位
    E_TEXT_DEMAND_VOLTAGE,//16	需求电压
    E_TEXT_DEMAND_CURRENT,//17	需求电流
    E_TEXT_REMAINTIME,//18	剩余时间
    E_TEXT_SOC,//	19	SOC
    E_TEXT_POWERUSE,//	20	已充度数
    E_TEXT_STATE,//	21	状态
    E_TEXT_OUTPUT_VOLTAGE,//	22	输出电压
    E_TEXT_OUTPUT_CUEERNT,//	23	输出电流
    E_TEXT_TIME_USE,//	24	已充时间
    E_TEXT_TOTAL_POWER,//	25	总度数
    E_TEXT_TOTAL_TIME,//	26	总耗时
    E_TEXT_TOTAL_COST,//	27	总费用
    E_TEXT_RECORDTITLE,//	28	记录标题
    E_TEXT_PAGENO,//	29	页码序号
    E_TEXT_PAGETOTAL,//	30	页码总数
    E_TEXT_RECORDTYPE,//	31	记录类型

    E_TEXT_MANTYPE =E_TEXT_BASE+40,//管理界面键
    /*
    E_TEXT_MANTYPE+1,//		管理界面键1
    ...		...
    E_TEXT_MANTYPE+n		管理界面键n
    */
    E_TEXT_MANVALUE = E_TEXT_BASE+80,//管理界面值
    /*
    E_TEXT_MANVALUE+1	 	管理界面值1
    ...
    E_TEXT_MANVALUE+n
    */

//图标控件
    E_ICON_BASE =E_CONTROL_BASE +200,

    E_ICON_LOGO,//	1	公司logo
    E_ICON_NET,//	2	网络图标

    E_ICON_GUN = E_ICON_BASE+10,
    /*
    E_ICON_GUN+1	 = 10	充电枪1图标
    E_ICON_GUN+2		充电枪2图标
    ...		...
    E_ICON_GUN+n		充电枪n图标
    */

//RTC控件类		
    E_RTC_BASE = E_CONTROL_BASE + 230,
    E_RTC_TIME,//	1	界面时间
    E_RTC_CNT,//	2	倒计时

//二维码控件
    E_QRCODE_BASE = E_CONTROL_BASE+240,
    E_QRCODE_WECHAT ,//1	扫码关注
    E_QRCODE_CHARGING,//2	扫码充电

//进度条控件类		
    E_PROGRESS_BASE = E_CONTROL_BASE+250,
    E_PROGRESS_SOC,//	1	充电soc  
		
//后备添加的		
   E_BACKUP_BASE  = E_CONTROL_BASE+270,
   E_TEXT_KWH	,//1	充电功率
   E_TEXT_ELECPCS	,//2	当前电费单价
   E_TEXT_SERVERPCS	,//3	当前服务费单价
   E_TEXT_ELECCOST	,//4	累计充电电费
   E_TEXT_SERVERCOST,//	5	累计充电服务费
   E_TEXT_TOTALCOST	,//6	累计总费用
   E_BUTTON_CHARGEINFO	,//7	充电信息控件
   E_BUTTON_COSTINFO	,//8	费用信息控件
   E_TEXT_REMAINTIMESECOND	,//9	剩余时间文本
   E_BUTTON_BYMONEY	,//10	按金额充
   E_BUTTON_FRIST_PAGE,//11	首页
   E_BUTTON_SELEC_PAGE	,//12	筛选
   E_TEXT_SYSDATE	,//13//	系统设置时间与日期
   E_TEXT_SYSDEDVNUM	,//14	系统设置桩编号
   E_TEXT_SYSPASSWORD	,//15	密码
   E_TEXT_SYSREPASSWORD	,//16	新密码
   E_TEXT_SYSASSETNUM	,//17	资产编码
   E_TEXT_SYSSERVEIP	,//18	远程ip
   E_TEXT_SYSMASK	,//19	子网掩码
   E_TEXT_SYSPORT	,//20	端口
   E_TEXT_SYSGW	,//21	网关
   E_TEXT_SYSLOCALIP	,//22	本地IP
   E_TEXT_SYSMAC	,//23	mac地址
   E_TEXT_SYSMAX_VOLTAGE	,//24	电压最大
   E_TEXT_SYSMAX_CURRENT	,//25	电流最大
};

struct t_nwgun
{
   struct t_prodevyx yx;
   struct t_prodevyc yc;
   char gunqrcode[128];
};
struct t_nw_screendata
{
    struct t_rtc time;
    struct t_proinitmsg proinitmsg;
    struct t_nwgun gunmsg[TOTALGUN];//枪信息
};
struct t_nwscreen
{
    struct t_driver _driver;

    uint32 netlogo;
    uint32 devnum;
    uint32 rtc;

    struct boot _boot;
    struct main_waitgun _mainwaitgun;
    struct way_select _wayselect;
    struct waitpwd _waitpwd;
    struct worktypeset _worktypeset;
    struct workvalue_time _workvalue_time;
    struct workvalue_power _workvalue_power;
    struct workvalue_money _workvalue_money;
    struct waitgun _waitgun;
    struct charging _charging;
    struct charging_cost _charging_cost;
    struct settle _settle;
    struct alarm _alarm;
    struct waitpwdmanage _waitpwdmanage;
    struct sysset1 _sysset1;
    struct sysset2 _sysset2;
    struct sysset3 _sysset3;
    struct sysset4 _sysset4;
    struct chargerecord _chargerecord;
    struct alarmrecord _alarmrecord;

    uint32 screennow;//当前画面id
    uint32 gunselect;//当前枪号选择
		
    struct t_nw_screendata screendata;
};
#define GUI_VER "DACAI_NW_1.1.1.1"

static struct t_nwscreen nwscreen;

static struct t_contrilmsg contrilmsgbuf[] =
{
// screenid controlid  hide value *str *deal;
//主界面单枪
   {E_SCREEN_MAIN_WAITGUN,E_BUTTON_MANAGE,0,0,0,(uint8 *)&nwscreen._mainwaitgun.screendeal},
	 {E_SCREEN_MAIN_WAITGUN,E_BUTTON_GUN+1,0,0,0,0},
//选择启动方式界面
   {E_SCREEN_WAYSELECT,E_TEXT_POINTMSG,0,0,0,(uint8 *)&nwscreen._wayselect.screendeal},
   {E_SCREEN_WAYSELECT,E_QRCODE_CHARGING,0,0,0,0},
//等待输入密码界面
   {E_SCREEN_WAITPWD,E_TEXT_CARDNO,0,0,0,(uint8 *)&nwscreen._waitpwd.screendeal},
   {E_SCREEN_WAITPWD,E_TEXT_PASSWORD,0,0,0,0},
   {E_SCREEN_WAITPWD,E_TEXT_POINTMSG,0,0,0,0},
   {E_SCREEN_WAITPWD,E_BUTTON_MAKESURE,0,0,0,0},
   {E_SCREEN_WAITPWD,E_BUTTON_RETURN,0,0,0,0},
	 {E_SCREEN_WAITPWD,E_RTC_CNT,0,0,0,0},
//设置充电类型界面
   {E_SCREEN_WORKTYPE_SET,E_RTC_CNT,0,0,0,(uint8 *)&nwscreen._worktypeset.screendeal},
   {E_SCREEN_WORKTYPE_SET,E_BUTTON_BYAUTO,0,0,0,0},
   {E_SCREEN_WORKTYPE_SET,E_BUTTON_BYTIME,0,0,0,0},
   {E_SCREEN_WORKTYPE_SET,E_BUTTON_BYPOWER,0,0,0,0},
	 {E_SCREEN_WORKTYPE_SET,E_BUTTON_BYMONEY,0,0,0,0},
   {E_SCREEN_WORKTYPE_SET,E_TEXT_POINTMSG,0,0,0,0},
   {E_SCREEN_WORKTYPE_SET,E_BUTTON_CANCEL,0,0,0,0},
//设置充电时长界面
	 {E_SCREEN_WORKVALUE_SET_TIME,E_RTC_CNT,0,0,0,(uint8 *)&nwscreen._workvalue_time.screendeal},
	 {E_SCREEN_WORKVALUE_SET_TIME,E_TEXT_PARASET_VALUE,0,0,0,0},
	 {E_SCREEN_WORKVALUE_SET_TIME,E_TEXT_POINTMSG,0,0,0,0},
   {E_SCREEN_WORKVALUE_SET_TIME,E_BUTTON_MAKESURE,0,0,0,0},
   {E_SCREEN_WORKVALUE_SET_TIME,E_BUTTON_RETURN,0,0,0,0},
	 {E_SCREEN_WORKVALUE_SET_TIME,E_BUTTON_CANCEL,0,0,0,0},
//设置充电电量界面
	 {E_SCREEN_WORKVALUE_SET_POWER,E_RTC_CNT,0,0,0,(uint8 *)&nwscreen._workvalue_power.screendeal},
	 {E_SCREEN_WORKVALUE_SET_POWER,E_TEXT_PARASET_VALUE,0,0,0,0},
	 {E_SCREEN_WORKVALUE_SET_POWER,E_TEXT_POINTMSG,0,0,0,0},
   {E_SCREEN_WORKVALUE_SET_POWER,E_BUTTON_MAKESURE,0,0,0,0},
   {E_SCREEN_WORKVALUE_SET_POWER,E_BUTTON_RETURN,0,0,0,0},
	 {E_SCREEN_WORKVALUE_SET_POWER,E_BUTTON_CANCEL,0,0,0,0},
//设置充电金额界面
	 {E_SCREEN_WORKVALUE_SET_MONEY,E_RTC_CNT,0,0,0,(uint8 *)&nwscreen._workvalue_money.screendeal},
	 {E_SCREEN_WORKVALUE_SET_MONEY,E_TEXT_PARASET_VALUE,0,0,0,0},
	 {E_SCREEN_WORKVALUE_SET_MONEY,E_TEXT_POINTMSG,0,0,0,0},
   {E_SCREEN_WORKVALUE_SET_MONEY,E_BUTTON_MAKESURE,0,0,0,0},
   {E_SCREEN_WORKVALUE_SET_MONEY,E_BUTTON_RETURN,0,0,0,0},
	 {E_SCREEN_WORKVALUE_SET_MONEY,E_BUTTON_CANCEL,0,0,0,0},
//等待枪连接界面
   {E_SCREEN_WAITGUN,E_RTC_CNT,0,0,0,(uint8 *)&nwscreen._waitgun.screendeal},
   {E_SCREEN_WAITGUN, E_BUTTON_CANCEL,0,0,0,0},
//充电中界面(交流)
    {E_SCREEN_CHARGING,E_BUTTON_CHARGEINFO,0,0,0,(uint8 *)&nwscreen._charging.screendeal},
    {E_SCREEN_CHARGING,E_BUTTON_COSTINFO,0,0,0,0},
    {E_SCREEN_CHARGING,E_TEXT_TIME_USE,0,0,0,0},
    {E_SCREEN_CHARGING,E_TEXT_POWERUSE,0,0,0,0},
    {E_SCREEN_CHARGING,E_TEXT_OUTPUT_VOLTAGE,0,0,0,0},
    {E_SCREEN_CHARGING,E_TEXT_OUTPUT_CUEERNT,0,0,0,0},
    {E_SCREEN_CHARGING,E_TEXT_KWH,0,0,0,0},
    {E_SCREEN_CHARGING,E_TEXT_STATE,0,0,0,0},
    {E_SCREEN_CHARGING,E_TEXT_POINTMSG,0,0,0,0},
//充电中界面_费用信息
    {E_SCREEN_CHARGING_COST,E_BUTTON_CHARGEINFO,0,0,0,(uint8 *)&nwscreen._charging_cost.screendeal},
    {E_SCREEN_CHARGING_COST,E_BUTTON_COSTINFO,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_TEXT_ELECPCS,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_TEXT_SERVERPCS,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_TEXT_ELECCOST,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_TEXT_SERVERCOST,0,0,0,0},
    {E_SCREEN_CHARGING_COST,E_TEXT_TOTALCOST,0,0,0,0},
    {E_SCREEN_CHARGING,E_TEXT_POINTMSG,0,0,0,0},
//结算界面
    {E_SCREEN_SETTLE,E_RTC_CNT,0,0,0,(uint8 *)&nwscreen._settle.screendeal},
    {E_SCREEN_SETTLE,E_TEXT_TOTAL_POWER,0,0,0,0},
    {E_SCREEN_SETTLE,E_TEXT_TOTAL_TIME,0,0,0,0},
    {E_SCREEN_SETTLE,E_TEXT_TOTAL_COST,0,0,0,0},
    {E_SCREEN_SETTLE,E_TEXT_POINTMSG,0,0,0,0},
    {E_SCREEN_SETTLE,E_BUTTON_MAKESURE,0,0,0,0},
//告警界面
    {E_SCREEN_ALARM,E_BUTTON_MANAGE,0,0,0,(uint8 *)&nwscreen._alarm.screendeal},
//等待输入密码界面(管理界面)
	  {E_SCREEN_WAITPWD_MANAGE,E_RTC_CNT,0,0,0,(uint8 *)&nwscreen._waitpwdmanage.screendeal},
    {E_SCREEN_WAITPWD_MANAGE,E_TEXT_PASSWORD,0,0,0,0},
    {E_SCREEN_WAITPWD_MANAGE,E_TEXT_POINTMSG,0,0,0,0},
    {E_SCREEN_WAITPWD_MANAGE,E_BUTTON_MAKESURE,0,0,0,0},
    {E_SCREEN_WAITPWD_MANAGE,E_BUTTON_CANCEL,0,0,0,0},
//系统设置1
		{E_SCREEN_SYSSET1,E_TEXT_SYSDATE,0,0,0,(uint8 *)&nwscreen._sysset1.screendeal},
    {E_SCREEN_SYSSET1,E_TEXT_SYSDEDVNUM,0,0,0,0},
   	{E_SCREEN_SYSSET1,E_TEXT_SYSPASSWORD,0,0,0,0},
   	{E_SCREEN_SYSSET1,E_TEXT_SYSREPASSWORD,0,0,0,0},
   	{E_SCREEN_SYSSET1,E_TEXT_SYSASSETNUM,0,0,0,0},
		{E_SCREEN_SYSSET1,E_BUTTON_RETURN,0,0,0,0},
		{E_SCREEN_SYSSET1,E_BUTTON_NEXT,0,0,0,0},
		{E_SCREEN_SYSSET1,E_BUTTON_SAVE,0,0,0,0},
//系统设置2
    {E_SCREEN_SYSSET2,E_TEXT_SYSSERVEIP,0,0,0,(uint8 *)&nwscreen._sysset2.screendeal},
    {E_SCREEN_SYSSET2,E_TEXT_SYSMASK,0,0,0,0},
    {E_SCREEN_SYSSET2,E_TEXT_SYSPORT,0,0,0,0},
    {E_SCREEN_SYSSET2,E_TEXT_SYSGW,0,0,0,0},
    {E_SCREEN_SYSSET2,E_TEXT_SYSLOCALIP,0,0,0,0},
    {E_SCREEN_SYSSET2,E_TEXT_SYSMAC,0,0,0,0},
		{E_SCREEN_SYSSET2,E_BUTTON_RETURN,0,0,0,0},
		{E_SCREEN_SYSSET2,E_BUTTON_FRONT,0,0,0,0},
		{E_SCREEN_SYSSET2,E_BUTTON_NEXT,0,0,0,0},
		{E_SCREEN_SYSSET2,E_BUTTON_SAVE,0,0,0,0},
//系统设置3		
		{E_SCREEN_SYSSET3,E_TEXT_SYSMAX_VOLTAGE,0,0,0,(uint8 *)&nwscreen._sysset3.screendeal},
		{E_SCREEN_SYSSET3,E_TEXT_SYSMAX_CURRENT,0,0,0,0},
		{E_SCREEN_SYSSET3,E_BUTTON_RETURN,0,0,0,0},
		{E_SCREEN_SYSSET3,E_BUTTON_FRONT,0,0,0,0},
		{E_SCREEN_SYSSET3,E_BUTTON_NEXT,0,0,0,0},
		{E_SCREEN_SYSSET3,E_BUTTON_SAVE,0,0,0,0},
//系统设置4
    {E_SCREEN_SYSSET4,E_TEXT_VERSOFTWARE,0,0,0,(uint8 *)&nwscreen._sysset4.screendeal},	
		{E_SCREEN_SYSSET4,E_BUTTON_CHARGERECORD,0,0,0,0},	
    {E_SCREEN_SYSSET4,E_BUTTON_ALARMRECORD,0,0,0,0},	
		{E_SCREEN_SYSSET4,E_BUTTON_RETURN,0,0,0,0},	
		{E_SCREEN_SYSSET4,E_BUTTON_FRONT,0,0,0,0},	
		{E_SCREEN_SYSSET4,E_BUTTON_NEXT,0,0,0,0},	
//充电记录界面
		{E_SCREEN_CHARGERECORD,E_BUTTON_FRIST_PAGE,0,0,0,(uint8 *)&nwscreen._chargerecord.screendeal},
		{E_SCREEN_CHARGERECORD,E_BUTTON_FRONT,0,0,0,0},
		{E_SCREEN_CHARGERECORD,E_BUTTON_NEXT,0,0,0,0},	
	  {E_SCREEN_CHARGERECORD,E_BUTTON_RETURN,0,0,0,0},			
    {E_SCREEN_CHARGERECORD,E_BUTTON_SELEC_PAGE,0,0,0,0},	
		{E_SCREEN_CHARGERECORD,E_TEXT_MANVALUE+1,0,0,0,0},
		{E_SCREEN_CHARGERECORD,E_TEXT_MANVALUE+2,0,0,0,0},
		{E_SCREEN_CHARGERECORD,E_TEXT_MANVALUE+3,0,0,0,0},
		{E_SCREEN_CHARGERECORD,E_TEXT_MANVALUE+4,0,0,0,0},
		{E_SCREEN_CHARGERECORD,E_TEXT_MANVALUE+5,0,0,0,0},
//告警记录界面
		{E_SCREEN_ALARMRECORD,E_BUTTON_FRIST_PAGE,0,0,0,(uint8 *)&nwscreen._alarmrecord.screendeal},
		{E_SCREEN_ALARMRECORD,E_BUTTON_FRONT,0,0,0,0},
		{E_SCREEN_ALARMRECORD,E_BUTTON_NEXT,0,0,0,0},	
	  {E_SCREEN_ALARMRECORD,E_BUTTON_RETURN,0,0,0,0},
		{E_SCREEN_ALARMRECORD,E_TEXT_MANVALUE+1,0,0,0,0},
		{E_SCREEN_ALARMRECORD,E_TEXT_MANVALUE+2,0,0,0,0},
		{E_SCREEN_ALARMRECORD,E_TEXT_MANVALUE+3,0,0,0,0},
		{E_SCREEN_ALARMRECORD,E_TEXT_MANVALUE+4,0,0,0,0},
		{E_SCREEN_ALARMRECORD,E_TEXT_MANVALUE+5,0,0,0,0},
		{E_SCREEN_ALARMRECORD,E_TEXT_MANVALUE+6,0,0,0,0},
		{E_SCREEN_ALARMRECORD,E_TEXT_MANVALUE+7,0,0,0,0},
		{E_SCREEN_ALARMRECORD,E_TEXT_MANVALUE+8,0,0,0,0},
		{E_SCREEN_ALARMRECORD,E_TEXT_MANVALUE+9,0,0,0,0},
};

static uint8 isgunnoover(char *gunno)
{
    uint32 tmpgunno = atoi(gunno);
    if(tmpgunno > atoi(nwscreen.screendata.proinitmsg.gunnum)){
       return 1;
    }
    return 0;
}
static struct t_contrilmsg *MEM_GETCONTROLID(uint32 screenid,uint32 controlid)
{
    uint32 len = sizeof(contrilmsgbuf)/sizeof(struct t_contrilmsg);
    return memgetcontrolid(contrilmsgbuf,len,screenid,controlid);
}
static struct t_screendeal *MEM_GETDEAL(uint32 screenid)
{
    uint32 len = sizeof(contrilmsgbuf)/sizeof(struct t_contrilmsg);
    return memgetdeal(contrilmsgbuf,len,screenid);
}
static uint8 isequal(const char *src, const char *dst)
{
   if(strlen(dst) == 0)
   {
       return 0;
   }
   if(strlen(src) != strlen(dst))
   {
       return 0;
   }
   return (strncmp(src, dst, strlen(dst)) == 0);

}

static void changetoscreen(uint32 screen)
{
   nwscreen.screennow = screen;
   
   char *pnetstate = nwscreen.screendata.gunmsg[0].yx.netstate;
   uint32 netvalue = 0;
   if(isequal(pnetstate,"netoff"))
   {
       netvalue = 0;
   }
   else if(isequal(pnetstate,"neton"))
   {
        netvalue = 1;
   }
   struct t_contrilmsg net = {0};
   net.screenid = nwscreen.screennow;
   net.controlid = nwscreen.netlogo;
   men_seticonvalue(&net,netvalue);
   
   char tmpdevnum[50] = {0};
   sprintf(tmpdevnum,"桩编号:%s",nwscreen.screendata.proinitmsg.devnum);
   struct t_contrilmsg devnum = {0};
   devnum.screenid = nwscreen.screennow;
   devnum.controlid = nwscreen.devnum;
   mem_settextvalue(&devnum,tmpdevnum);
   
   mem_setscreen(screen);
	 
   struct t_screendeal *deal = MEM_GETDEAL(screen);
   if(deal && deal->_initscreen)
   {
        deal->_initscreen();
   }
}
static void hidecontrolsingle(void)
{
  
}

static void setgunselect(uint32 gunselect)
{
   nwscreen.gunselect = gunselect;
}
static void resetscreen()
{
  changetoscreen(E_SCREEN_MAIN_WAITGUN);
	setgunselect(1);
}

static void changetoscreencharging(void)
{
   char *pdevtype = nwscreen.screendata.proinitmsg.devtype;

   if(isequal(pdevtype,"ac"))//如果是交流设备
   {
     changetoscreen(E_SCREEN_CHARGING);
   }
   else if(isequal(pdevtype,"dc"))//如果是直流设备
   {
      //changetoscreen(E_SCREEN_CHARGING_DC);
   }
}
static void changetoscreenalarm(void)
{
	 /*
   if(issinglegun())
   {
      mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_REMAINTIMESECOND),0);
      mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_RTC_CNT),0);
      mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_BUTTON_RETURN),0);
   }
   else
   {
       mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_REMAINTIMESECOND),1);
       mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_RTC_CNT),1);
       mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_ALARM,E_BUTTON_RETURN),1);
   }
   sprintf(gtcscreen._alarm.screentype,"%s",ALARMMSG);
   mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_ALARM,E_TEXT_TITLE1),"设备故障,暂停使用");
   */
   changetoscreen(E_SCREEN_ALARM);

}
static void updatenetstate(char *gunno,char *netstate)
{
   uint32 tmpgunno = atoi(gunno);
   uint32 pos = tmpgunno -1;
   char *pnetstate = nwscreen.screendata.gunmsg[pos].yx.netstate;
   if(isequal(netstate,pnetstate))
   {
     return ;
   }
   uint8 tmpstate = 0;
   if(isequal(netstate,"netoff"))
   {
       tmpstate = 0;
   }
   else if(isequal(netstate,"neton"))
   {
         tmpstate = 1;
   }
   struct t_contrilmsg  control = {0};
   control.screenid = nwscreen.screennow;
   control.controlid = nwscreen.netlogo;
  
   men_seticonvalue(&control,tmpstate);

  
}
static void updategunstate(char *gunno,char *gunstate)
{  
   uint32 tmpgunno = atoi(gunno);
   uint32 pos = tmpgunno -1;

   char *pgunstate = nwscreen.screendata.gunmsg[pos].yx.gunstate;
   if(isequal(gunstate,pgunstate))
   {
     return ;
   }
   #if 0
   uint8 tmpstate = 0;

   if(isequal(gunstate,"idle"))
   {
      tmpstate = 0;
   }
   else if(isequal(gunstate,"charging"))
   {
      tmpstate = 1;
   }
   else if(isequal(gunstate,"alarm"))
   {
      tmpstate = 2;
   }
  // men_seticonvalue(MEM_GETCONTROLID(E_SCREEN_MAIN_DOUBLE,E_ICON_GUN+tmpgunno),tmpstate);
   #endif
}

static uint8 isgunconnect(uint8 gunno)
{
	  if(gunno <=0 ||
			 gunno > atoi(nwscreen.screendata.proinitmsg.gunnum))
		{
			 return  0;
		}
    char *tmpconnectstate = nwscreen.screendata.gunmsg[gunno-1].yx.connectstate;
    if(isequal(tmpconnectstate,"connect"))
    {
       return 1;
    }
    return 0;
}
static uint8 isneton(void)
{
	char *pnetstate = nwscreen.screendata.gunmsg[0].yx.netstate;
	return (strncmp(pnetstate,"neton", strlen(pnetstate)) == 0);
}

static void SETTEXT(struct t_contrilmsg *text,char *dst,char *src)
{
    if(strlen(src) == 0)
    {
       return ;
    }

    if(isequal(dst,src))
    {
      return ;
    }
    mem_settextvalue(text,src);
}

static void pollmainwaitgun()
{
	 if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_BUTTON_GUN+1))){
		 changetoscreen(E_SCREEN_WAITGUN);
	 }
	 if(isgunconnect(nwscreen.gunselect)){
	  changetoscreen(E_SCREEN_WAYSELECT);
	 }
	 if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_MAIN_WAITGUN,E_BUTTON_MANAGE))){
		 changetoscreen(E_SCREEN_WAITPWD_MANAGE);
	 }
}

static void reloadingmainwaitgun()
{
	
}
static void pollwayselect()
{
	 if(!isgunconnect(nwscreen.gunselect)){
	   resetscreen();
	 }
	 if(!isneton()){//网络未连接
		 mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_TEXT_POINTMSG),"网络连接中 请稍等......");
	 }else{
		  mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_TEXT_POINTMSG),"如需充电请直接刷卡或扫码");
	 }
	  
}
static void reloadingwayselect()
{
	
}
static void pollwaitpwd()
{
	
}
static void reloadingwaitpwd()
{
	
}
static void pollworktypeset()
{
	
}
static void reloadingworktypeset()
{
	
}
static void pollworkvalue_time()
{
	
}
static void reloadingworkvalue_time()
{
	
}
static void pollworkvalue_power()
{
	
}
static void reloadingworkvalue_power()
{
	
}
static void pollworkvalue_money()
{
	
}
static void reloadingworkvalue_money()
{
	
}		
static void pollwaitgun()
{
	 if(isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_WAITGUN,E_BUTTON_CANCEL)) || 
		 isrtctimeout(MEM_GETCONTROLID(E_SCREEN_WAITGUN,E_RTC_CNT))){
		     resetscreen();
	}			
  if(isgunconnect(nwscreen.gunselect)){
	  changetoscreen(E_SCREEN_WAYSELECT);
	 }		 
}
static void  reloadingwaitgun()
{
	beginrtc(MEM_GETCONTROLID(E_SCREEN_WAITGUN,E_RTC_CNT),20);
}	
static void pollcharging()
{
	 struct t_contrilmsg *pcostinfo = MEM_GETCONTROLID(E_SCREEN_CHARGING,E_BUTTON_COSTINFO);
   // struct t_contrilmsg *pstop = MEM_GETCONTROLID(E_SCREEN_CHARGING_AC,E_BUTTON_STOP);
   if(isbutton_trigger(pcostinfo)){
	   changetoscreen(E_SCREEN_CHARGING_COST);
   }
	 /*
   if(isbutton_trigger(pstop))
   {
      changetocommunicatestop();
   }
	 */
}
static uint8 chargingac_updateyc(char * gunno,struct t_prodevyc *yc)
{
    uint32 tmpgunno = atoi(gunno);
    if(tmpgunno !=  nwscreen.gunselect){
       return  0;
    }
	  uint32 pos = tmpgunno -1 ;
	
    struct t_prodevyc *ycdst = &nwscreen.screendata.gunmsg[pos].yc;
	  struct t_prodevyc *ycsrc = yc;

    uint32 screenid = E_SCREEN_CHARGING;
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TIME_USE),ycdst->charingtime,ycsrc->charingtime);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_POWERUSE),ycdst->chargingpower,ycsrc->chargingpower);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_VOLTAGE),ycdst->outputvoltage,ycsrc->outputvoltage);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_CUEERNT),ycdst->outputcurrent,ycsrc->outputcurrent);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_KWH),ycdst->outputkwh,ycsrc->outputkwh);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_STATE),ycdst->devstate,ycsrc->devstate);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_POINTMSG),ycdst->chargingpoingmsg,ycsrc->chargingpoingmsg);
    return 1;
}
static void reloadingcharging()
{
	  uint32 pos = nwscreen.gunselect-1;
    struct t_prodevyc *yc = &nwscreen.screendata.gunmsg[pos].yc;
    uint32 screenid = E_SCREEN_CHARGING;

    mem_controlenable(MEM_GETCONTROLID(screenid,E_BUTTON_CHARGEINFO),0);

    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TIME_USE),yc->charingtime);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_POWERUSE),yc->chargingpower);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_VOLTAGE),yc->outputvoltage);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_OUTPUT_CUEERNT),yc->outputcurrent);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_KWH),yc->outputkwh);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_STATE),yc->devstate);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_POINTMSG),yc->chargingpoingmsg);
}	 
static void pollcharging_cost()
{
	  struct t_contrilmsg *pcharginginfo = MEM_GETCONTROLID(E_SCREEN_CHARGING_COST,E_BUTTON_CHARGEINFO);
    if(isbutton_trigger(pcharginginfo)){
        changetoscreencharging();
    }
}
static void reloadingcharging_cost()
{ 
	  uint32 pos = nwscreen.gunselect-1;
    struct t_prodevyc *yc = &nwscreen.screendata.gunmsg[pos].yc;
    uint32 screenid = E_SCREEN_CHARGING_COST;

    mem_controlenable(MEM_GETCONTROLID(screenid,E_BUTTON_COSTINFO),0);

    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_ELECPCS),yc->elecpcs);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_SERVERPCS),yc->serverpcs);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_ELECCOST),yc->eleccost);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_SERVERCOST),yc->servercost);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TOTALCOST),yc->totalcost);
}
static uint8  chargingcost_updateyc(char * gunno,struct t_prodevyc *yc)
{
    uint32 tmpgunno = atoi(gunno);
	if(tmpgunno !=	nwscreen.gunselect)
	{
	  return  0;
	}
	uint32 pos = tmpgunno -1 ;
		
  struct t_prodevyc *ycdst = &nwscreen.screendata.gunmsg[pos].yc;
	struct t_prodevyc *ycsrc = yc;

    uint32 screenid = E_SCREEN_CHARGING_COST;
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_ELECPCS),ycdst->elecpcs,ycsrc->elecpcs);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_SERVERPCS),ycdst->serverpcs,ycsrc->serverpcs);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_ELECCOST),ycdst->eleccost,ycsrc->eleccost);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_SERVERCOST),ycdst->servercost,ycsrc->servercost);
    SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TOTALCOST),ycdst->totalcost,ycsrc->totalcost);
    return 1;
}
static void  pollsettle()
{
	   if(isrtctimeout(MEM_GETCONTROLID(E_SCREEN_SETTLE,E_RTC_CNT)) ||
      (isbutton_trigger(MEM_GETCONTROLID(E_SCREEN_SETTLE,E_BUTTON_RETURN))))
    {
       resetscreen();	   
    }
}
static void reloadingsettle()
{
	  uint32 pos = nwscreen.gunselect-1;
    struct t_prodevyc *yc = &nwscreen.screendata.gunmsg[pos].yc;
    uint32 screenid = E_SCREEN_SETTLE;

    beginrtc(MEM_GETCONTROLID(screenid,E_RTC_CNT),5);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_COST),yc->settlecost);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_POWER),yc->settlepower);
    mem_settextvalue(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_TIME),yc->settletime);
} 
static uint8  settle_updateyc(char * gunno,struct t_prodevyc *yc)
{
  uint32 tmpgunno = atoi(gunno);
	if(tmpgunno !=	nwscreen.gunselect)
	{
	  return 0;
	}
	uint32 pos = tmpgunno -1 ;
		 
  struct t_prodevyc *ycdst = &nwscreen.screendata.gunmsg[pos].yc;
	struct t_prodevyc *ycsrc = yc;

  uint32 screenid = E_SCREEN_SETTLE;

  SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_COST),ycdst->settlecost,ycsrc->settlecost);
  SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_POWER),ycdst->settlepower,ycsrc->settlepower);
  SETTEXT(MEM_GETCONTROLID(screenid,E_TEXT_TOTAL_TIME),ycdst->settletime,ycsrc->settletime);
  return 1;
}
static void pollalarm()
{
	
}
static void reloadingalarm()
{
	
} 
static void pollwaitpwdmanage()
{
	
} 
static void reloadingwaitpwdmanage()
{
	
}
static void pollsysset1()
{
	
}	
static void reloadingsysset1()
{
	
}	
static void pollsysset2()
{
	
}
static void reloadingsysset2()
{
	
}
 static void pollsysset3()
{
	
}
static void reloadingsysset3()
{
	
}
static void pollsysset4()
{
	
}	
static void reloadingsysset4()
{
	
}	 
static void pollchargerecord()
{
	
}
static void reloadingchargerecord()
{
	
}	 
static void pollalarmrecord()
{
	
}
static void reloadingalarmrecord()
{
	
} 
#if 0		
static void dealsysytypevalue(uint16 screen_id, uint16 control_id, char *str)
{
	 /*
   uint32 flag = gtcscreen._sysvalueset.flag;
   if(0 == flag)//为0时先记录被改的配置文件的位置
   {
     if(control_id <= E_TEXT_MANVALUE+MANAGEMAX ||
         control_id >= E_TEXT_MANVALUE+1 )
     {
         uint32 pos = control_id - E_TEXT_MANVALUE -1;
         *(gtcscreen._sysvalueset.driver+pos) = 1;
    }
   }
   else if(2 == flag)//为1时记录值
   {
       if(control_id <= E_TEXT_MANTYPE+MANAGEMAX &&
          control_id >= E_TEXT_MANTYPE+1 )
	   {
           sprintf(gtcscreen._sysvalueset.type,"%s",str);
	   }
       else if(control_id <= E_TEXT_MANVALUE+MANAGEMAX &&
          control_id >= E_TEXT_MANVALUE+1 )
	   {
           sprintf(gtcscreen._sysvalueset.value,"%s",str);
	   }
   }
   */
}
#endif
static unsigned char bcd_to_hex(unsigned char data)
{
    unsigned char temp;

    temp = ((data>>4)*10 + (data&0x0f));
    return temp;
}
static void nw_NOTIFYHandShake(void)//握手通知
{
	
}
static void nw_NotifyScreen(uint16 screen_id)//画面切换通知
{
	
}
static void nw_NotifyButton(uint16 screen_id, uint16 control_id, uint8 state)//按钮控件通知
{
	
    if(screen_id != nwscreen.screennow)
    {
        return ;
    }
    struct t_contrilmsg *pbutton = MEM_GETCONTROLID(screen_id,control_id);
    button_trigger(pbutton,state);
	
}
static void nw_NotifyText(uint16 screen_id, uint16 control_id, uint8 *str)//文本通知信息
{   
	
    if(screen_id != nwscreen.screennow)
    {
        return ;
    }
		/*
    if(E_SCREEN_TYPEVALUE_SET == gtcscreen.screennow)
    {
        dealsysytypevalue(screen_id,control_id,(char *)str);
    }else
		*/
    {
       struct t_contrilmsg *ptext = MEM_GETCONTROLID(screen_id,control_id);
       driver_settextvalue(ptext,(char *)str);
    }
	
}
static void nw_NotifyProgress(uint16 screen_id, uint16 control_id, uint32 value)//进度条通知
{
	
}
static void nw_NotifySlider(uint16 screen_id,uint16 control_id,uint16 value)//滑块条控件
{

}
static void nw_NotifyMeter(uint16 screen_id,uint16 control_id,uint16 value)//仪表盘控件
{
	
}
static void nw_NotifyMenu(uint16 screen_id, uint16 control_id, uint8 item, uint8 state)//菜单控件
{
	
}
static void nw_NotifySelector(uint16 screen_id, uint16 control_id, uint8  item)//选择控件
{
	
}
static void nw_NotifyTimer(uint16 screen_id, uint16 control_id)//倒计时控件
{
    if(screen_id != nwscreen.screennow){
        return ;
    }
    struct t_contrilmsg *pcnt = MEM_GETCONTROLID(screen_id,control_id);
    rtctimeout(pcnt);
}
static void nw_NotifyReadRTC(uint8 year,uint8 month,uint8 week,uint8 day,uint8 hour,uint8 minute,uint8 second)//rtc时间读取通知
{
     nwscreen.screendata.time.year = bcd_to_hex(year);
     nwscreen.screendata.time.month = bcd_to_hex(month);
     nwscreen.screendata.time.date = bcd_to_hex(day);
     nwscreen.screendata.time.hour = bcd_to_hex(hour);
     nwscreen.screendata.time.minute = bcd_to_hex(minute);
     nwscreen.screendata.time.second = bcd_to_hex(second);
     nwscreen.screendata.time.weekend = bcd_to_hex(week);

     nwscreen.screendata.time.timestate = 1;	
}

void mem_init(void)
{
    memset((uint8 *)&nwscreen,0,sizeof(nwscreen));

    nwscreen._driver._NOTIFYHandShak  = nw_NOTIFYHandShake;
    nwscreen._driver._NotifyScreen = nw_NotifyScreen;
    nwscreen._driver._NotifyButton = nw_NotifyButton;
    nwscreen._driver._NotifyText = nw_NotifyText;
    nwscreen._driver._NotifyProgress = nw_NotifyProgress;
    nwscreen._driver._NotifySlider = nw_NotifySlider;
    nwscreen._driver._NotifyMeter = nw_NotifyMeter;
    nwscreen._driver._NotifyMenu = nw_NotifyMenu;
    nwscreen._driver._NotifySelector = nw_NotifySelector;
    nwscreen._driver._NotifyTimer = nw_NotifyTimer;
    nwscreen._driver._NotifyReadRTC = nw_NotifyReadRTC;

    driver_init(&nwscreen._driver);
	
    nwscreen.netlogo = E_ICON_NET;
    nwscreen.devnum = E_TEXT_DEVNUM;
    nwscreen.rtc = 0;
		
//主界面单枪
    struct main_waitgun *pmainwaitgun = &nwscreen._mainwaitgun;
    pmainwaitgun->screendeal._initscreen = reloadingmainwaitgun;
    pmainwaitgun->screendeal._pollscreen = pollmainwaitgun;
//选择启动方式界面
    struct way_select *pwayselect = &nwscreen._wayselect;
    pwayselect->screendeal._initscreen = reloadingwayselect;
    pwayselect->screendeal._pollscreen = pollwayselect;
//等待输入密码界面
    struct waitpwd *pwaitpwd = &nwscreen._waitpwd;
    pwaitpwd->screendeal._initscreen = reloadingwaitpwd;
    pwaitpwd->screendeal._pollscreen = pollwaitpwd;
    //pwaitpwd->screendeal._getpwdauth = waitpwd_getpwdauth;
//设置充电类型界面
    struct worktypeset *pworktypeset = &nwscreen._worktypeset;
    pworktypeset->screendeal._initscreen = reloadingworktypeset;
    pworktypeset->screendeal._pollscreen = pollworktypeset;
    //pworktypeset->screendeal._getyaokong = worktypeset_screengetyk;
//设置按时间充界面		
		struct workvalue_time  *pworkvaluetime = &nwscreen._workvalue_time;
		pworkvaluetime->screendeal._initscreen = reloadingworkvalue_time;
		pworkvaluetime->screendeal._pollscreen = pollworkvalue_time;
//设置按度数充界面
    struct workvalue_power *pworkvaluepower = &nwscreen._workvalue_power;
		pworkvaluepower->screendeal._initscreen = reloadingworkvalue_power;
		pworkvaluepower->screendeal._pollscreen = pollworkvalue_power;
//设置按金额充界面
    //struct workvalue_money *pworkvaluemoney = &nwscreen._workvalue_money;
		pworkvaluepower->screendeal._initscreen = reloadingworkvalue_money;
		pworkvaluepower->screendeal._pollscreen = pollworkvalue_money;
//等待枪连接界面
    struct waitgun *pwaitgun = &nwscreen._waitgun;
    pwaitgun->screendeal._initscreen = reloadingwaitgun;
    pwaitgun->screendeal._pollscreen = pollwaitgun;
//充电中界面(交流)
    struct charging *pcharging = &nwscreen._charging;
    pcharging->screendeal._initscreen = reloadingcharging;
    pcharging->screendeal._pollscreen = pollcharging;
    pcharging->screendeal._dealscreenupdateyc = chargingac_updateyc;
//充电中界面_费用信息
    struct charging_cost *pchargingcost = &nwscreen._charging_cost;
    pchargingcost->screendeal._initscreen = reloadingcharging_cost;
    pchargingcost->screendeal._pollscreen = pollcharging_cost;
    pchargingcost->screendeal._dealscreenupdateyc = chargingcost_updateyc;
//结算界面
    struct settle *psettle = &nwscreen._settle;
    psettle->screendeal._initscreen = reloadingsettle;
    psettle->screendeal._pollscreen = pollsettle;
    psettle->screendeal._dealscreenupdateyc = settle_updateyc;
//告警界面
    struct alarm *palarm = &nwscreen._alarm;
    palarm->screendeal._initscreen = reloadingalarm;
    palarm->screendeal._pollscreen = pollalarm;
    //palarm->screendeal._dealscreenupdateyc = alarm_updateyc;
//等待输入密码界面(管理界面)
    struct waitpwdmanage *pmanagewaitpwd = &nwscreen._waitpwdmanage;
    pmanagewaitpwd->screendeal._initscreen = reloadingwaitpwdmanage;
    pmanagewaitpwd->screendeal._pollscreen = pollwaitpwdmanage;
    //pmanagewaitpwd->screendeal._getpwdauth = manwaitpwd_getpwdauth;
//系统设置1		
    struct sysset1 *psysset1 = &nwscreen._sysset1;
		psysset1->screendeal._initscreen = reloadingsysset1;
		psysset1->screendeal._pollscreen = pollsysset1;
//系统设置2			
    struct sysset2 *psysset2 = &nwscreen._sysset2;
    psysset2->screendeal._initscreen = reloadingsysset2;
		psysset2->screendeal._pollscreen = pollsysset2;
//系统设置3	
		//struct sysset3 *psysset3 = &nwscreen._sysset3;
    psysset2->screendeal._initscreen = reloadingsysset3;
		psysset2->screendeal._pollscreen = pollsysset3;
//系统设置4	
		//struct sysset4 *psysset4 = &nwscreen._sysset4;
		psysset2->screendeal._initscreen = reloadingsysset4;
		psysset2->screendeal._pollscreen = pollsysset4;
//充电记录    
		struct chargerecord *pchargerecord = &nwscreen._chargerecord;
  	pchargerecord->screendeal._initscreen = reloadingchargerecord;
		pchargerecord->screendeal._pollscreen = pollchargerecord;
//告警记录		
		struct alarmrecord *palarmrecord = &nwscreen._alarmrecord;
		palarmrecord->screendeal._initscreen = reloadingalarmrecord;
		palarmrecord->screendeal._pollscreen = pollalarmrecord;
}
void mem_poll(void)
{
   driver_poll();
   struct t_screendeal *deal = MEM_GETDEAL(nwscreen.screennow);
   if(deal && deal->_pollscreen){
     deal->_pollscreen();
   }	
}
void mem_setrtc(const char *time)
{
	  char year[5] = {0};
    char month[3] = {0};
    char date[3] = {0};
    char hour[3] = {0};
    char minute[3] = {0};
    char second[3] = {0};
    char weekend[3] = {0};

    memcpy(year,time,sizeof(year)-1);
    memcpy(month,time+4,sizeof(month)-1);
    memcpy(date,time+6,sizeof(date)-1);
    memcpy(hour,time+8,sizeof(hour)-1);
    memcpy(minute,time+10,sizeof(minute)-1);
    memcpy(second,time+12,sizeof(second)-1);
    memcpy(weekend,time+14,sizeof(weekend)-1);

    struct t_rtc rtc;
    rtc.year = atoi(year)-2000;
    rtc.month = atoi(month);
    rtc.date = atoi(date);
    rtc.hour = atoi(hour);
    rtc.minute = atoi(minute);
    rtc.second = atoi(second);
    rtc.weekend = atoi(weekend);

    setrtc(rtc.year,rtc.month,rtc.date,rtc.hour,rtc.minute,rtc.second,rtc.weekend);
}
uint8 mem_getrtc(char *time)
{
  if(!nwscreen.screendata.time.timesendstate)//没有发送读取rtc的
  {
      readrtc();
      nwscreen.screendata.time.timesendstate = 1;
      return 0;
  }
  if(!nwscreen.screendata.time.timestate)//数据没有回来
  {
      return 0;
  }
  //数据回来了
  struct t_rtc rtc;
  rtc.year = nwscreen.screendata.time.year;
  rtc.month =nwscreen.screendata.time.month;
  rtc.date = nwscreen.screendata.time.date;
  rtc.hour = nwscreen.screendata.time.hour;
  rtc.minute = nwscreen.screendata.time.minute;
  rtc.second = nwscreen.screendata.time.second;
  rtc.weekend = nwscreen.screendata.time.weekend;

  memset((uint8 *)&nwscreen.screendata.time,0,sizeof(struct t_rtc));
  sprintf(time,"%02d%02d%02d%02d%02d%02d%02d",rtc.year,rtc.month,rtc.date,rtc.hour,rtc.minute,rtc.second,rtc.weekend);
  return 1;
}

uint8 mem_getyk(struct t_prodevyk *yk)
{
	struct t_screendeal *deal = MEM_GETDEAL(nwscreen.screennow);
  if(deal && deal->_getyaokong)
  {
    return deal->_getyaokong(yk);
  }
  return 0;
}
void  mem_updatedevyx(const char *gunno,const struct t_prodevyx *yxmsg)
{
	 if(isgunnoover((char *)gunno))
   {
        return ;
   }
   uint32 tmpgunno = atoi(gunno);

   char *pgunstate = nwscreen.screendata.gunmsg[tmpgunno-1].yx.gunstate;
   if(!isequal(pgunstate,yxmsg->gunstate) && atoi(gunno) == nwscreen.gunselect)//如果是当前枪的状态发生改变
   {
     if(isequal(yxmsg->gunstate,"idle"))//
     {
        resetscreen();
     }
     if(isequal(yxmsg->gunstate,"charging"))//如果是转到充电状态
     {
        changetoscreencharging();//加载为充电界面
     }
     else if(isequal(yxmsg->gunstate,"alarm"))
     {
        changetoscreenalarm();//加载为告警界面
     }
     else if(isequal(yxmsg->gunstate,"settle"))
     {
        changetoscreen(E_SCREEN_SETTLE);
     }
   }
   updatenetstate((char *)gunno,(char *)yxmsg->netstate);
   updategunstate((char *)gunno,(char *)yxmsg->gunstate);
	
   memcpy((void *)&nwscreen.screendata.gunmsg[tmpgunno-1].yx,(void *)yxmsg,sizeof(struct t_prodevyx));
}
void  mem_updatedevyc(const char *gunno,const struct t_prodevyc *ycmsg)
{
	 if(isgunnoover((char *)gunno)){
        return ;
    }
    uint32 tmpgunno = atoi(gunno);
    uint8 pos = tmpgunno -1 ;
    struct t_prodevyc *pyc = &nwscreen.screendata.gunmsg[pos].yc;
    if(tmpgunno == nwscreen.gunselect)
    {
        struct t_screendeal *deal = MEM_GETDEAL(nwscreen.screennow);
        if(deal && deal->_dealscreenupdateyc)
        {
             deal->_dealscreenupdateyc((char *)gunno,(struct t_prodevyc *)ycmsg);
        }
    }
    memcpy((uint8 *)pyc,(uint8 *)ycmsg,sizeof(struct t_prodevyc));
}
uint8 mem_getpwdauth(struct t_pwdauth *auth)
{
	struct t_screendeal *deal = MEM_GETDEAL(nwscreen.screennow);
  if(deal && deal->_getpwdauth){
    return deal->_getpwdauth(auth);
  }
  return 0;
}
void  mem_pwdauthack(char *gunno,struct t_pwdauthack *pwdauthack)
{
	   if (isequal(pwdauthack->type,"manauth")){
        if(isequal(pwdauthack->flag,"succ")){//认证成功
          changetoscreen(E_SCREEN_SYSSET1);
        }
        else if(isequal(pwdauthack->flag,"fail")){//认证失败
          mem_settextvalue( MEM_GETCONTROLID(E_SCREEN_WAITPWD_MANAGE,E_TEXT_POINTMSG),"密码错误,请重新输入");
        }
   }
   else if(isequal(pwdauthack->type,"cardauth")){
       if(atoi(gunno) != nwscreen.gunselect){
          return ;
       }
       if(isequal(pwdauthack->flag,"succ")){//认证成功
         changetoscreen(E_SCREEN_WORKTYPE_SET);
       }
       else if(isequal(pwdauthack->flag,"fail")){//认证失败
           mem_settextvalue( MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_POINTMSG),"密码错误,请重新输入");
       }
   }
}
uint8 mem_getfilecheck(struct t_filecheck *filecheck)
{
	 struct t_screendeal * deal = MEM_GETDEAL(nwscreen.screennow);
   if(deal && deal->_screengetfilecheck){
      return   deal->_screengetfilecheck(filecheck);
   }
   return 0;
}
void  mem_filecheckack(struct t_filecheckack *filecheck)
{
	  struct t_screendeal * deal = MEM_GETDEAL(nwscreen.screennow);
    if (deal && deal->_screenfilecheckack)
    {
      deal->_screenfilecheckack(filecheck);
    }
}
uint8 mem_getfilechange(struct t_filechange *filechange)
{
	 struct t_screendeal * deal = MEM_GETDEAL(nwscreen.screennow);
   if (deal && deal->_screenfilechange){
      return deal->_screenfilechange(filechange);
   }
   return 0;
}
uint8 mem_getguiver(char *ver)
{
	 sprintf(ver,"%s",GUI_VER);
   return 1;
}
void mem_initgui(const struct t_proinitmsg *msg)
{
    memcpy((uint8 *)&nwscreen.screendata.proinitmsg,(uint8 *)msg,sizeof(struct t_proinitmsg));

    //mem_showcontrol(MEM_GETCONTROLID(E_SCREEN_CHARGING_C,E_BUTTON_STOP),0);//停止充电控件隐藏

    hidecontrolsingle();
    resetscreen();
}
void mem_setscreenmsg(char *gunno,char *type,char *str)
{
	 if(isgunnoover(gunno))
   {
       return ;
   }
   uint32 tmpgunno = atoi(gunno);
   if(isequal(type,"qr_charging"))
   {    
      uint32 pos = tmpgunno - 1;
      sprintf(nwscreen.screendata.gunmsg[pos].gunqrcode,"%s",str);
      if(nwscreen.gunselect == tmpgunno)
      {
         mem_setqrcodevalue(MEM_GETCONTROLID(E_SCREEN_WAYSELECT,E_QRCODE_CHARGING),(uint8 *)str);
      }
   }
}
void mem_startauth(char *gunno,struct t_startauth *auth)
{
	 if (atoi(gunno) != nwscreen.gunselect)
    {
        return ;
    }
    if (isequal(auth->flag,"authing")){
       if (isequal(auth->authtype,"qrcode_auth")){
           // poingmsgscreenmsg("提 示 信 息","设备启动中......");
       }
    }
    else if(isequal(auth->flag,"succ"))
    {
       if(isequal(auth->authtype,"card_auth")){
          if (isequal(auth->pwdtype,"pwdneed")){          
             mem_settextvalue(MEM_GETCONTROLID(E_SCREEN_WAITPWD,E_TEXT_CARDNO),auth->cardno);
             changetoscreen(E_SCREEN_WAITPWD);
          }else if(isequal(auth->pwdtype,"pwdno")){
             changetoscreen(E_SCREEN_WORKTYPE_SET);
          }
       }
    }
    else if(isequal(auth->flag,"fail"))
    {
       //startauthfail("启 动 失 败 ！",auth->failreason);
    }
}
